package com.atguigu.bigdata.scala.mytest.chapter06


object Test9 {
  def main(args: Array[String]): Unit = {
    val user = new User
    println("isInstanceOf:"+user.isInstanceOf[Hello])
    user.eat()
//    Hello
//    Person
//    Student
//    Teacher
//    User
//    ========================================
//    isInstanceOf:true
//    User eat
//      Teacher eat
//      Student eat
//      Person eat
  }

  class Hello {
    println("Hello")
    def eat():Unit={
      println("Hello eat")
    }
  }

  trait Person {
    println("Person")
    def eat():Unit={
      println("Person eat")

    }
  }

  trait Teacher extends Person {
    println("Teacher")
    override def eat():Unit={
      println("Teacher eat")
      super.eat()
    }
  }

  trait Student extends Person {
    println("Student")
    override def eat():Unit={
      println("Student eat")
      super.eat()
    }
  }

  //初始化从左往右,先初始化父类Hello再初始化特质Student->Teacher
  //同一个继承体系(User,Student,Teacher,Person)中super调用可以画饼
  class User extends Hello  with Student with Teacher{
    println("User")
    println("========================================")
    override def eat():Unit={
      println("User eat")
      super.eat()
    }

  }


}
